<?php

	class map_category_DAO extends CI_Model{

		public function __construct(){
			parent::__construct();
			$this->load->database();
		}

		public function get($category_level_1_id, $category_level_2_id){
			$query = $this->db->query("SELECT id, vi_name, en_name FROM category_level_3, map_category WHERE map_category.category_level_3_id = category_level_3.id and map_category.category_level_2_id = {$category_level_2_id} and map_category.category_level_1_id = {$category_level_1_id}");
			return $query->result_array();
		}
		
		public function add($map_category){
			$this->db->insert("map_category", $map_category);
			return ($this->db->affected_rows() != 1) ? false : true;
		}
		
		public function delete($category_level_1_id, $category_level_2_id){
			$this->db->where('category_level_1_id', $category_level_1_id);
			$this->db->where('category_level_2_id', $category_level_2_id);
			$this->db->delete('map_category');
		}		
	}

?>